﻿#include "Window.h"
#include "main.h"


int APIENTRY wWinMain(
    _In_ HINSTANCE, 
    _In_opt_ HINSTANCE,
    _In_ LPWSTR,
    _In_ int)
{
    try
    {
        Window wnd(600, 400, "Donkey Fart Box");

        MSG msg = {};
        while (msg.message != WM_QUIT) {     // 非退出事件
            if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
                TranslateMessage(&msg);//翻译消息
                DispatchMessage(&msg);//分发消息
            }
            //其它工作
            wnd.MainLoop();
        }
 
        return (int) msg.wParam;
    }
    catch (const ChiliException& e) {
        MessageBox(nullptr, e.what(), e.GetType(), MB_OK | MB_ICONEXCLAMATION);
    }
    catch (const std::exception& e) {
        MessageBox(nullptr, e.what(), "standard Exception", MB_OK | MB_ICONEXCLAMATION);
    }
    catch (...) {
        MessageBox(nullptr, "No details available", "Unknown Exception", MB_OK | MB_ICONEXCLAMATION);
    }
    return -1;
}
